<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateRefundRecordTableMigration extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $this->table('refund_record', ['id' => false, 'primary_key' => ['id']])
            ->addColumn('id', 'integer', ['identity' => true])
            ->addColumn('type', 'string', ['limit' => 16,'default'=>'biz-order', 'comment' => '退款类型'])
            ->addColumn('item_id', 'integer', ['limit'=>11,'default'=>0,'comment' => '关联ID'])
            ->addColumn('refund_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '退款金额'])
            ->addColumn('refund_at', 'integer', ['comment' => '退款时间', 'default' => 0])
            ->addColumn('status', 'string', ['limit' => 16, 'default' => 'doing', 'comment' => '状态doing,success,failed'])
            ->addColumn('created_at', 'integer', ['comment' => '创建时间'])
            ->addColumn('updated_at', 'integer', ['comment' => '更新时间'])
            ->create();
    }
}
